/**
 * 
 */
package com.james.android.pingtu;

import android.content.Context;

import com.james.android.utils.PreferencesUtils;

/**
 * 游戏全局变量
 * @author Winter Lau
 */
public class GameGlobal {

	private static Context context;	
	private static PreferencesUtils putils;

	public final static int COMPLEX_DEGREE = 500;
	
	public final static int CELL_ROW = 4;
	public final static int CELL_COL = 4;
	
	public final static String PREF_KEY_IMAGE 	= "img";
	private final static String PREF_KEY_AUDIO 	= "audio";
	public final static String PREFS_KEY_CELLS 	= "cells";	
	private final static String PREF_KEY_HABIT = "left_hand";
	
	public static int[] pics = {R.drawable.mouse,
						  R.drawable.hansome,
						  R.drawable.kid,
						  R.drawable.boy,
						  R.drawable.girl,
						  R.drawable.fixed,
						  R.drawable.leaf,
						  R.drawable.ohmygod
				};
	
	public static int default_pic = pics[0];
	
	public static void init(Context ctx){
		context = ctx;
		putils = new PreferencesUtils(context);
	}
	
	public static String read(String key) {
		return putils.read(key, null);
	}
	
	public static void remove(String key) {
		putils.remove(key);
	}
	
	public static void write(String key, String value) {
		putils.write(key, value);
	}
	
	public static int get_pic(){
		int pic = putils.read(PREF_KEY_IMAGE, GameGlobal.default_pic);
		return (pic>0)?pic:default_pic;
	}
	
	public static void save_pic(int pic) {
		if(pic > 0)
			putils.write(PREF_KEY_IMAGE, pic);
	}
	
	public static boolean is_audio_on() {
		return putils.read(PREF_KEY_AUDIO, true);
	}
	
	public static void set_audio(boolean on) {
		putils.write(PREF_KEY_AUDIO, on);
	}
	
	public static boolean is_left_hand(){
		return putils.read(PREF_KEY_HABIT, false);
	}
	
	public static void set_left_hand(boolean left) {
		putils.write(PREF_KEY_HABIT, left);
	}
}
